package com.zb.internetSpider.utils;

import java.awt.Dimension;
import java.awt.Font;
import java.awt.GraphicsEnvironment;
import java.awt.Toolkit;

public class CommonUtils {

	public static Dimension getHalfScreenSize() {
		Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
		dimension.setSize(dimension.getWidth() /2 , dimension.getHeight() /2);
		return dimension;
	}
	public static Dimension getScreenSize() {
		Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
		dimension.setSize(dimension.getWidth(), dimension.getHeight());
		return dimension;
	}
	public static Dimension getScreenSize(double times) {
		Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
		dimension.setSize(dimension.getWidth() * times, dimension.getHeight() * times);
		return dimension;
	}
	
	/**
	 * <p>返回当前操作系统的字体</p>
	 * @return
	 */
	public static String[] getSystemFontNames() {		
		return GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
	}
	
	
	
	public static Font[] getSystemFonts(){
		return GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
	}
	/**
	 * 
	 * @Description: TODO 判断当前系统是否含有该字体
	 * @param @param name
	 * @param @return   
	 * @return boolean  
	 * @throws
	 * @author zb
	 * @date 2019年2月14日 下午5:31:08
	 */
	public static boolean isExistFont(String name) {
		boolean exist = false;
		for(String fn : GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames()){
			if(fn.equals(name.trim())) {
				exist = true;
				break;
			}
			
		}
		return exist;
	}
	
	public static void main(String[] args) {
		for(String f: GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames()){
			System.out.println(f);
		}
	}

}
